package com.competition.web.admin.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.competition.param.impl.UserParam;
import com.competition.web.admin.service.IUserService;
import com.competition.web.entity.User;
import com.page.PageResponseData;
import com.param.impl.IdParam;
import com.param.impl.PageParam;
import com.response.vo.ResponseModel;


@RestController()
@RequestMapping("/user")
public class UserController {
	
	@Autowired
	private IUserService userService;
	
	@PostMapping("/getUserListByStatus")
	public ResponseModel<List<User>> getUserListByStatus() {
		return ResponseModel.success(this.userService.getUserListByStatus());
	}
	
	/**
	 * 用户列表
	 * @param pageParam
	 * @return
	 */
	@PostMapping("/getUserList")
	public  ResponseModel<PageResponseData<User>> getUserList(@RequestBody @Validated PageParam pageParam) {
		return ResponseModel.success(this.userService.getDataByList(pageParam));
	}
	
	/**
	 * 用户列表
	 * @param pageParam
	 * @return
	 */
	@PostMapping("/getUserListBySearch")
	public  ResponseModel<PageResponseData<User>> getUserListBySearch(@RequestBody @Validated UserParam pageParam) {
		return ResponseModel.success(this.userService.getDataByListBySearch(pageParam));
	}
	
	/**
	 * 用户列表
	 * @param pageParam
	 * @return
	 */
	@PostMapping("/userInfo")
	public  ResponseModel<User> getUserInfo(@RequestBody @Validated IdParam param) {
		return ResponseModel.success(this.userService.selectByPrimaryKey(param.getId()));
	}
	
	
}
